package com.wxit.algorithm.tree;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class TestBSTTree {

    public BSTTree1 createBSTTree() {
        BSTTree1.BSTNode n1 = new BSTTree1.BSTNode(1, "吴杰");
        BSTTree1.BSTNode n3 = new BSTTree1.BSTNode(3, "李沁");

        BSTTree1.BSTNode n2 = new BSTTree1.BSTNode(2, "高城", n1, n3);
        BSTTree1.BSTNode n5 = new BSTTree1.BSTNode(5, "菜刀");
        BSTTree1.BSTNode n7 = new BSTTree1.BSTNode(7, "班长");
        BSTTree1.BSTNode n6 = new BSTTree1.BSTNode(6, "锄头", n5, n7);

        BSTTree1.BSTNode root = new BSTTree1.BSTNode(4, "许三多", n2, n6);
        BSTTree1 tree = new BSTTree1();
        tree.root = root;
        return tree;
    }

    public BSTTree2<String, String> createBSTTreeV() {
        BSTTree2.BSTNode<String, String> n1 = new BSTTree2.BSTNode<>("1", "吴杰");
        BSTTree2.BSTNode<String, String> n3 = new BSTTree2.BSTNode<>("3", "李沁");

        BSTTree2.BSTNode<String, String> n2 = new BSTTree2.BSTNode<>("2", "高城", n1, n3);
        BSTTree2.BSTNode<String, String> n5 = new BSTTree2.BSTNode<>("5", "菜刀");
        BSTTree2.BSTNode<String, String> n7 = new BSTTree2.BSTNode<>("7", "班长");
        BSTTree2.BSTNode<String, String> n6 = new BSTTree2.BSTNode<>("6", "锄头", n5, n7);

        BSTTree2.BSTNode<String, String> root = new BSTTree2.BSTNode<>("4", "许三多", n2, n6);
        BSTTree2<String, String> tree = new BSTTree2<>();
        tree.root = root;
        return tree;
    }

    @Test
    public void get() {
        BSTTree2<String, String> tree = createBSTTreeV();
        assertEquals("吴杰", tree.get("1"));
    }
}
